{% extends "layouts/layout01.html" %}

{% load markup i18n %}

{% block content %}

    <h2>{% trans "Текстовые поля" %}</h2>
    
    {{ form }}
    
    {% with object.text_fields.all as object_list %}
    <table class="table table-bordered table-striped table-highlight">
        <thead>
        <tr>
            <th>{% trans "Ключ" %}</th>
            <th>{% trans "Значение" %}</th>
            <th>{% trans "Действия" %}</th>

        </tr>
        </thead>
        <tbody>
            
        {% for object in object_list %}
            <tr>
                <td>{{ object.key }}</td>
                <td>{{ object.value }}</td>
                <td>
                    
                    <a href="#" class="btn">{% trans "Редактировать" %}</a>
                    
                    <a href="{% url delete_record pk=object.id  %}" class="btn">Elfkvbn</a>
                    
                </td>
            </tr>
        {% empty %}
        
            <tr>
                <td colspan="3">
                    {% trans "Не создано ни одного поля" %}
                </td>
            </tr>
        {% endfor %}
        </tbody>
        <tfoot>
            <tr>
                <td colspan="3">
                
                <section id="modals">
                <a class="btn" data-toggle="modal" href="#myModal">{% trans "Создать" %}</a>
                </section>
                
                </td>
            </tr>
        </tfoot>
    </table>
    {% endwith %}
    
    {% comment %}
                    <div class="modal fade hide" id="myModal">
                    
                    <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">×</button>
                    <h3>Modal header</h3>
                    </div>
                    
                    <div class="modal-body">
                    <p>
                        
                    <form id="text_form" method="post" target="">{% csrf_token %}
                    <input type="hidden" name="form-type" value="text-form" />
                    {% with text_formset as formset %}
                    {{ formset.management_form }}
                    <table id="id_forms_table" class="table table-bordered table-striped table-highlight">
                    <thead>
                    <tr>
                    <th>{% trans "Ключ" %}</th>
                    <th>{% trans "Значение" %}</th>

                    </tr>
                    </thead>
                    <tbody>
                    {% for form in formset %}
                    <tr id="{{ form.prefix }}-row">
                    <td {% if form.key.errors %}style="background-color: red;"{% endif %}>{% for fld in form.hidden_fields %}{{ fld }}{% endfor %}{{ form.key }}</td>
                    <td {% if form.value.errors %}style="background-color: red;"{% endif %}>{{ form.value }}</td>
                    <td>{% if form.key.value %}
                    <a href="#" class="btn"><i class="icon-trash"></i></a>
                    {% endif %}
                    </td>
                    </tr>
                    {% empty %}
                    <tr>
                    <td colspan="3">
                    {% trans "Не создано ни одного поля" %}
                    </td>
                    </tr>
                    {% endfor %}
                    </tbody>
                    <tfoot>
                    <tr>
                    <td colspan="3">
                    <button type="submit" class="btn btn-primary"><i class="icon-star"></i>Сохранить</button>
                    <a class="btn" href="javascript:void(0)" id="add_row">{% trans "Добавить в Сет" %}</a>
                    </td>
                    </tr>
                    </tfoot>
                    </table>
                    {% endwith %}
                    </form>
                    
                    </p>
                    </div>
                    
                    <div class="modal-footer">
                    <a href="javascript:;" class="btn" data-dismiss="modal">Close</a>
                    <a href="javascript:;" class="btn btn-primary">Save changes</a>
                    </div>
                    
                    </div>
   {% endcomment %} 
    
   
    <form id="text_form" method="post" target="">{% csrf_token %}
    
   {% comment %}  
    <input type="hidden" name="form-type" value="text-form" />
    {% with text_formset as formset %}
        {{ formset.management_form }}
        <table id="id_forms_table" class="table table-bordered table-striped table-highlight">
            <thead>
            <tr>
                <th>{% trans "Ключ" %}</th>
                <th>{% trans "Значение" %}</th>
                <th>{% trans "Actions" %}</th>

            </tr>
            </thead>
            <tbody>
            {% for form in formset %}
                <tr id="{{ form.prefix }}-row">
                    <td {% if form.key.errors %}style="background-color: red;"{% endif %}>{% for fld in form.hidden_fields %}{{ fld }}{% endfor %}{{ form.key }}</td>
                    <td {% if form.value.errors %}style="background-color: red;"{% endif %}>{{ form.value }}</td>
                    <td>{% if form.key.value %}
                        <a href="#" class="btn"><i class="icon-trash"></i></a>
                        {% endif %}
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="3">
                        {% trans "Не создано не одного поля" %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
            <tfoot>
            <tr>
                <td colspan="3">
                    <button type="submit" class="btn btn-primary"><i class="icon-star"></i>Сохранить</button>
                    <a class="btn" href="javascript:void(0)" id="add_row">{% trans "Добавить в Сет" %}</a>
                </td>
            </tr>
            </tfoot>
        </table>
    {% endwith %}
{% endcomment %}

    </form>







    <h2>{% trans "Графичисrrrкие поля" %}</h2>


    <form id="image_form" method="post" target="" enctype="multipart/form-data">{% csrf_token %}
        <input type="hidden" name="form-type" value="image-form" />
        {% with image_formset as formset %}
            {% if formset.errors %}
                <b>{% for error in formset.errors  %}{{ error }}; {% endfor %} </b>
            {% endif %}
            {{ formset.management_form }}
            <table id="id_forms_table" class="table table-bordered table-striped table-highlight">
                <thead>
                <tr>
                    <th>{% trans "Ключ" %}</th>
                    <th>{% trans "Значение" %}</th>
                    <th></th>

                </tr>
                </thead>
                <tbody>
                {% for form in formset %}
                    <b>{% for error in form.errors  %}{{ error }}; {% endfor %} </b>
                    <tr id="{{ form.prefix }}-row" >
                        <td>{% for fld in form.hidden_fields %}{{ fld }}{% endfor %}{{ form.key }}   {% for error in form.key.errors  %}{{ error }}; {% endfor %}</td>
                        <td>{{ form.value }} {% for error in form.value.errors  %}{{ error }}; {% endfor %} </td>
                        <td>{% if form.key.value %}
                            <a href="#" class="btn"><i class="icon-trash"></i></a>
                        {% endif %}
                        </td>
                    </tr>
                {% empty %}
                    <tr>
                        <td colspan="3">
                            {% trans "Не создано не одного поля" %}
                        </td>
                    </tr>
                {% endfor %}
                </tbody>
                <tfoot>
                <tr>
                    <td colspan="3">
                        <button type="submit" class="btn btn-primary"><i class="icon-star"></i>Сохранить</button>
                    </td>
                </tr>
                </tfoot>
            </table>
        {% endwith %}
    </form>



<!--
    {% comment %}
    {% with object.image_field.all as object_list %}
        <table class="table table-bordered table-striped table-highlight">
            <thead>
            <tr>
                <th>{% trans "Ключ" %}</th>
                <th>{% trans "Значение" %}</th>
                <th></th>

            </tr>
            </thead>
            <tbody>
            {% for object in object_list %}
                <tr>
                    <td>{{ object.key }}</td>
                    <td>{{ object.value }}</td>
                    <td><a href="#" class="btn"><i class="icon-trash"></i></a></td>
                </tr>
            {% empty %}
                <tr>
                    <td colspan="3">
                        {% trans "Не создано не одного поля" %}
                    </td>
                </tr>
            {% endfor %}
            </tbody>
            <tfoot>
            <tr>
                <td colspan="3">


                </td>
            </tr>
            </tfoot>
        </table>
    {% endwith %}
    {% endcomment %}
{% endblock %}
-->

{% block subscript %}
<script src="js/libs/jquery-1.7.2.min.js"></script>
<script src="js/libs/jquery-ui-1.8.21.custom.min.js"></script>
<script src="js/libs/jquery.ui.touch-punch.min.js"></script>

<script src="js/bootstrap.min.js"></script>

<script src="js/Theme.js"></script>

<script>

$(function () {
	
	Theme.init ();
	
});

</script>
{% endblock %}

{% block script %}

    <script type="text/javascript" src="{{ STATIC_URL }}js/formset.js"></script>
    <script>
    $(function () {
    $('#add_row').click(function() {
    console.log("Click");
    return addForm(this, 'form');
    });

    $('.delete-row').click(function() {
    return deleteForm(this, 'form');
    })
    });
    </script>
    <script src="js/libs/jquery-1.7.2.min.js"></script>
    <script src="js/libs/jquery-ui-1.8.21.custom.min.js"></script>
    <script src="js/libs/jquery.ui.touch-punch.min.js"></script>

    <script src="js/bootstrap.min.js"></script>

    <script src="js/Theme.js"></script>
    <script>
    $(function () {
    Theme.init ();
    });
    </script>
    
{% endblock %}

 <script src="js/libs/jquery-1.7.2.min.js"></script>
<script src="js/libs/jquery-ui-1.8.21.custom.min.js"></script>
<script src="js/libs/jquery.ui.touch-punch.min.js"></script>

<script src="js/bootstrap.min.js"></script>

<script src="js/Theme.js"></script>

<script>

$(function () {
	
	Theme.init ();
	
});


</script>   

